<?php /* Smarty version 2.6.20, created on 2012-03-16 19:24:52
         compiled from _core/_include/module/_mvc/control/handlepaymentproblems.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', '_core/_include/module/_mvc/control/handlepaymentproblems.tpl', 15, false),)), $this); ?>
function HandlePaymentProblems(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  
  this._name = (options && options.name) ? options.name : null;
  this._operator = (options && options.operator) ? options.operator : null;
  this._now = (options && options.now) ? options.now : null;
  this._smryGui = (options && options.smryGui) ? options.smryGui : null;
  this._smryArgs = (options && options.smryArgs) ? options.smryArgs : null;
  
  this._cond = (options && options.cond) ? options.cond : null;
  
  
  if (this._operator.type == '<?php echo ((is_array($_tmp=@USER_TYPE_ADMIN)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
    if (this._cond == 1) {
      this._condition = ' AND o.isPayment1FirstSolved != 2';
    } else if (this._cond == 2) {
      this._condition = ' AND o.isPayment1SecondSolved != 2';
    } else if (this._cond == 3) {
      this._condition = ' AND o.isPayment1ThirdSolved != 2';
    } else if (this._cond == 4) {
      this._condition = ' AND o.isPayment1ForthSolved != 2';
    } else if (this._cond == 5) {
      this._condition = ' AND o.isPayment2FirstSolved != 2';
    } else if (this._cond == 6) {
      this._condition = ' AND o.isPayment2SecondSolved != 2';
    } else if (this._cond == 7) {
      this._condition = ' AND o.isPayment3FirstSolved != 2';
    } else if (this._cond == 8) {
      this._condition = ' AND o.isPayment3SecondSolved != 2';
    } else if (this._cond == 9) {
      this._condition = ' AND o.isPayment4Solved != 2';
    } else if (this._cond == 10) {
      this._condition = ' AND o.isPaymentnoSolved != 2';
    }
    this._select = 1;
    this._type = '<?php echo ((is_array($_tmp=@APPROVE_TYPE_NOTAPPROVED)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
';
  } else {
    if (this._cond == 1) {
      this._condition = ' AND o.isPayment1FirstSolved = 0';
    } else if (this._cond == 2) {
      this._condition = ' AND o.isPayment1SecondSolved = 0';
    } else if (this._cond == 3) {
      this._condition = ' AND o.isPayment1ThirdSolved = 0';
    } else if (this._cond == 4) {
      this._condition = ' AND o.isPayment1ForthSolved = 0';
    } else if (this._cond == 5) {
      this._condition = ' AND o.isPayment2FirstSolved = 0';
    } else if (this._cond == 6) {
      this._condition = ' AND o.isPayment2SecondSolved = 0';
    } else if (this._cond == 7) {
      this._condition = ' AND o.isPayment3FirstSolved = 0';
    } else if (this._cond == 8) {
      this._condition = ' AND o.isPayment3SecondSolved = 0';
    } else if (this._cond == 9) {
      this._condition = ' AND o.isPayment4Solved = 0';
    } else if (this._cond == 10) {
      this._condition = ' AND o.isPaymentnoSolved = 0';
    }
    this._select = 1;
    this._type = '<?php echo ((is_array($_tmp=@SOLVE_TYPE_NOTSOLVED)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
';
  }
  
  this._createElements();
};

HandlePaymentProblems.prototype._createElements = function() {
  var  _self = this;
  
  if (this._operator.type == '<?php echo ((is_array($_tmp=@USER_TYPE_ADMIN)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
    this._button = DOMUtils.createInput('', '', 'button', 'Approve', null);
    this._gui.save.appendChild(this._button);
    
    for (var i = 0, il = ApproveType.array().length; i < il; i++) {
      var type = ApproveType.array()[i];
      option = new Option(type);
      this._gui.select.options[this._gui.select.options.length] = option;
      if (option.text == this._type) {
        this._gui.select.selectedIndex = this._gui.select.options.length - 1;
      }
    }
    
    this._gui.select.onchange = function() { _self._type = this.options[this.selectedIndex].text;
                                             if (_self._type == '<?php echo ((is_array($_tmp=@APPROVE_TYPE_NOTAPPROVED)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
                                               if (_self._cond == 1) {
                                                 _self._condition = ' AND o.isPayment1FirstSolved != 2';
                                               } else if (_self._cond == 2) {
                                                 _self._condition = ' AND o.isPayment1SecondSolved != 2';
                                               } else if (_self._cond == 3) {
                                                 _self._condition = ' AND o.isPayment1ThirdSolved != 2';
                                               } else if (_self._cond == 4) {
                                                 _self._condition = ' AND o.isPayment1ForthSolved != 2';
                                               } else if (_self._cond == 5) {
                                                 _self._condition = ' AND o.isPayment2FirstSolved != 2';
                                               } else if (_self._cond == 6) {
                                                 _self._condition = ' AND o.isPayment2SecondSolved != 2';
                                               } else if (_self._cond == 7) {
                                                 _self._condition = ' AND o.isPayment3FirstSolved != 2';
                                               } else if (_self._cond == 8) {
                                                 _self._condition = ' AND o.isPayment3SecondSolved != 2';
                                               } else if (_self._cond == 9) {
                                                 _self._condition = ' AND o.isPayment4Solved != 2';
                                               } else if (_self._cond == 10) {
                                                 _self._condition = ' AND o.isPaymentnoSolved != 2';
                                               }
                                               _self._select = 1;
                                             } else {
                                               _self._condition = ' AND 1 = 1';
                                               _self._select = 0;
                                             }
                                             _self._retrieveOrders(1);
                                           };
  } else {
    this._button = DOMUtils.createInput('', '', 'button', 'Solve', null);
    this._gui.save.appendChild(this._button);
    
    for (var i = 0, il = SolveType.array().length; i < il; i++) {
      var type = SolveType.array()[i];
      option = new Option(type);
      this._gui.select.options[this._gui.select.options.length] = option;
      if (option.text == this._type) {
        this._gui.select.selectedIndex = this._gui.select.options.length - 1;
      }
    }
    
    this._gui.select.onchange = function() { _self._type = this.options[this.selectedIndex].text;
                                             if (_self._type == '<?php echo ((is_array($_tmp=@SOLVE_TYPE_NOTSOLVED)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
                                               if (_self._cond == 1) {
                                                 _self._condition = ' AND o.isPayment1FirstSolved = 0';
                                               } else if (_self._cond == 2) {
                                                 _self._condition = ' AND o.isPayment1SecondSolved = 0';
                                               } else if (_self._cond == 3) {
                                                 _self._condition = ' AND o.isPayment1ThirdSolved = 0';
                                               } else if (_self._cond == 4) {
                                                 _self._condition = ' AND o.isPayment1ForthSolved = 0';
                                               } else if (_self._cond == 5) {
                                                 _self._condition = ' AND o.isPayment2FirstSolved = 0';
                                               } else if (_self._cond == 6) {
                                                 _self._condition = ' AND o.isPayment2SecondSolved = 0';
                                               } else if (_self._cond == 7) {
                                                 _self._condition = ' AND o.isPayment3FirstSolved = 0';
                                               } else if (_self._cond == 8) {
                                                 _self._condition = ' AND o.isPayment3SecondSolved = 0';
                                               } else if (_self._cond == 9) {
                                                 _self._condition = ' AND o.isPayment4Solved = 0';
                                               } else if (_self._cond == 10) {
                                                 _self._condition = ' AND o.isPaymentnoSolved = 0';
                                               }
                                               _self._select = 1;
                                             } else {
                                               if (_self._cond == 1) {
                                                 _self._condition = ' AND o.isPayment1FirstSolved != 2';
                                               } else if (_self._cond == 2) {
                                                 _self._condition = ' AND o.isPayment1SecondSolved != 2';
                                               } else if (_self._cond == 3) {
                                                 _self._condition = ' AND o.isPayment1ThirdSolved != 2';
                                               } else if (_self._cond == 4) {
                                                 _self._condition = ' AND o.isPayment1ForthSolved != 2';
                                               } else if (_self._cond == 5) {
                                                 _self._condition = ' AND o.isPayment2FirstSolved != 2';
                                               } else if (_self._cond == 6) {
                                                 _self._condition = ' AND o.isPayment2SecondSolved != 2';
                                               } else if (_self._cond == 7) {
                                                 _self._condition = ' AND o.isPayment3FirstSolved != 2';
                                               } else if (_self._cond == 8) {
                                                 _self._condition = ' AND o.isPayment3SecondSolved != 2';
                                               } else if (_self._cond == 9) {
                                                 _self._condition = ' AND o.isPayment4Solved != 2';
                                               } else if (_self._cond == 10) {
                                                 _self._condition = ' AND o.isPaymentnoSolved != 2';
                                               }
                                               _self._select = 0;
                                             }
                                             _self._retrieveOrders(1);
                                           };
  }
  
  this._loadData();
};

HandlePaymentProblems.prototype._verifyData = function() {
  if (this._orders) {
    this._updateElements();
  }
};

HandlePaymentProblems.prototype._loadData = function() {
  this._orders = null;
  this._parameters = null;
  this._retrieveOrders(1);
};

HandlePaymentProblems.prototype._retrieveOrders = function(page, pos) {
  var _self = this;
  var args = ((this._condition) ? '&c=' + this._condition : '') + '&p=' + page + '&s=20';
  new RequestUtils()._mysql(this._name, args, function(result, params) { _self._orders = result.data;
                                                                         _self._parameters = result;
                                                                         _self._verifyData.call(_self);
                                                                       }, { pos: pos });
};

HandlePaymentProblems.prototype._updateElements = function() {
  var _self = this;
  DOMUtils.removeChildElements(this._gui.page);
  DOMUtils.removeChildElements(this._gui.payment);
  
  if (this._smryGui && this._smryArgs) {
    if (this._operator.type == '<?php echo ((is_array($_tmp=@USER_TYPE_ADMIN)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
      if (this._select) {
        for (var i = 0, il = this._smryArgs.length; i < il; i++) {
          var smryArg = this._smryArgs[i];
          if (smryArg.cond == 1) {
            smryArg.condition = ' AND o.isPayment1FirstSolved != 2';
          }
          if (smryArg.cond == 2) {
            smryArg.condition = ' AND o.isPayment1SecondSolved != 2';
          }
          if (smryArg.cond == 3) {
            smryArg.condition = ' AND o.isPayment1ThirdSolved != 2';
          }
          if (smryArg.cond == 4) {
            smryArg.condition = ' AND o.isPayment1ForthSolved != 2';
          }
          if (smryArg.cond == 5) {
            smryArg.condition = ' AND o.isPayment2FirstSolved != 2';
          }
          if (smryArg.cond == 6) {
            smryArg.condition = ' AND o.isPayment2SecondSolved != 2';
          }
          if (smryArg.cond == 7) {
            smryArg.condition = ' AND o.isPayment3FirstSolved != 2';
          }
          if (smryArg.cond == 8) {
            smryArg.condition = ' AND o.isPayment3SecondSolved != 2';
          }
          if (smryArg.cond == 9) {
            smryArg.condition = ' AND o.isPayment4Solved != 2';
          }
          if (smryArg.cond == 10) {
            smryArg.condition = ' AND o.isPaymentnoSolved != 2';
          }
        }
      } else {
        for (var i = 0, il = this._smryArgs.length; i < il; i++) {
          var smryArg = this._smryArgs[i];
          if (smryArg.cond == 1) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 2) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 3) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 4) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 5) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 6) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 7) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 8) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 9) {
            smryArg.condition = ' AND 1 =1 ';
          }
          if (smryArg.cond == 10) {
            smryArg.condition = ' AND 1 =1 ';
          }
        }
      }
    } else {
      if (this._select) {
        for (var i = 0, il = this._smryArgs.length; i < il; i++) {
          var smryArg = this._smryArgs[i];
          if (smryArg.cond == 1) {
            smryArg.condition = ' AND o.isPayment1FirstSolved = 0';
          }
          if (smryArg.cond == 2) {
            smryArg.condition = ' AND o.isPayment1SecondSolved = 0';
          }
          if (smryArg.cond == 3) {
            smryArg.condition = ' AND o.isPayment1ThirdSolved = 0';
          }
          if (smryArg.cond == 4) {
            smryArg.condition = ' AND o.isPayment1ForthSolved = 0';
          }
          if (smryArg.cond == 5) {
            smryArg.condition = ' AND o.isPayment2FirstSolved = 0';
          }
          if (smryArg.cond == 6) {
            smryArg.condition = ' AND o.isPayment2SecondSolved = 0';
          }
          if (smryArg.cond == 7) {
            smryArg.condition = ' AND o.isPayment3FirstSolved = 0';
          }
          if (smryArg.cond == 8) {
            smryArg.condition = ' AND o.isPayment3SecondSolved = 0';
          }
          if (smryArg.cond == 9) {
            smryArg.condition = ' AND o.isPayment4Solved = 0';
          }
          if (smryArg.cond == 10) {
            smryArg.condition = ' AND o.isPaymentnoSolved = 0';
          }

        }
      } else {
        for (var i = 0, il = this._smryArgs.length; i < il; i++) {
          var smryArg = this._smryArgs[i];
          if (smryArg.cond == 1) {
            smryArg.condition = ' AND o.isPayment1FirstSolved != 2';
          }
          if (smryArg.cond == 2) {
            smryArg.condition = ' AND o.isPayment1SecondSolved != 2';
          }
          if (smryArg.cond == 3) {
            smryArg.condition = ' AND o.isPayment1ThirdSolved != 2';
          }
          if (smryArg.cond == 4) {
            smryArg.condition = ' AND o.isPayment1ForthSolved != 2';
          }
          if (smryArg.cond == 5) {
            smryArg.condition = ' AND o.isPayment2FirstSolved != 2';
          }
          if (smryArg.cond == 6) {
            smryArg.condition = ' AND o.isPayment2SecondSolved != 2';
          }
          if (smryArg.cond == 7) {
            smryArg.condition = ' AND o.isPayment3FirstSolved != 2';
          }
          if (smryArg.cond == 8) {
            smryArg.condition = ' AND o.isPayment3SecondSolved != 2';
          }
          if (smryArg.cond == 9) {
            smryArg.condition = ' AND o.isPayment4Solved != 2';
          }
          if (smryArg.cond == 10) {
            smryArg.condition = ' AND o.isPaymentnoSolved != 2';
          }

        }
      }
    }
    new HandleSmryAdmin(this._smryGui, null, { args: this._smryArgs });
  }
  
  this._selects = [];
  this._button.onclick = function() { if (_self._selects.length == 0) {
                                        window.alert('No Items Selected');
                                        return;
                                      }
                                      var orders = [];
                                      for(var i = 0, il = _self._selects.length; i < il; i++) {
                                        var object = _self._selects[i];
                                        orders[orders.length] = object.id;
                                      }
                                      if (_self._operator.type == '<?php echo ((is_array($_tmp=@USER_TYPE_ADMIN)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
                                        new RequestUtils()._mysql('paymentproblems1', '&o=' + JSON.stringify(orders) + '&c=' + _self._cond, function(result, params) { _self._retrieveOrders(1); }, { pos: DOMUtils.findPos(this) });
                                      } else {
                                        new RequestUtils()._mysql('paymentproblems', '&o=' + JSON.stringify(orders) + '&c=' + _self._cond, function(result, params) { _self._retrieveOrders(1); }, { pos: DOMUtils.findPos(this) });
                                      }
                                    };
  new TablePaymentProblem(this._gui.payment, this._orders, { user: this._operator, date: this._now, selects: this._selects, cond: this._cond, callbackFunc: function() { _self._retrieveOrders(1);} });
};